package com.zmcc.service.impl;

import com.google.gson.Gson;
import com.zmcc.entity.VoiceMeetingTemplate;
import com.zmcc.entity.common.CommonRequest;
import com.zmcc.service.IVoiceMeetingRequest;

import java.util.HashMap;
import java.util.Map;

public class VoiceMeetingRequestCommercial implements IVoiceMeetingRequest {

    private final static String url = "https://dev.cmccopen.cn/api";

    private static VoiceMeetingRequestCommercial voiceMeetingRequestCommercial;

    public static VoiceMeetingRequestCommercial getInstance() {
        if (voiceMeetingRequestCommercial == null){
            voiceMeetingRequestCommercial = new VoiceMeetingRequestCommercial();
        }
        return voiceMeetingRequestCommercial;
    }

    @Override
    public CommonRequest getMeetingAddRequest(VoiceMeetingTemplate template) {
        CommonRequest request = new CommonRequest();
        request.setUrl(url+"/v1"+"/voice"+"/meeting"+"/add");
        request.setBody(new Gson().toJson(template));
        return request;
    }

    @Override
    public CommonRequest getMeetingAddMemberRequest(VoiceMeetingTemplate template) {
        CommonRequest request = new CommonRequest();
        request.setUrl(url+"/v1"+"/voice"+"/meeting"+"/addmember");
        request.setBody(new Gson().toJson(template));
        return request;
    }

    @Override
    public CommonRequest getMeetingOperateRequest(String conf_id, String cmd, String number) {
        CommonRequest request = new CommonRequest();
        request.setUrl(url+"/v1"+"/voice"+"/meeting"+"/operate");
        Map<String,String> bodyMap = new HashMap<>();
        bodyMap.put("conf_id",conf_id);
        bodyMap.put("cmd",cmd);
        bodyMap.put("number",number);
        request.setBody(new Gson().toJson(bodyMap));
        return request;
    }

    @Override
    public CommonRequest getMeetingGetDetailRequest(String conf_id) {
        CommonRequest request = new CommonRequest();
        request.setUrl(url+"/v1"+"/voice"+"/meeting"+"/getDetail");
        Map<String,String> bodyMap = new HashMap<>();
        bodyMap.put("conf_id",conf_id);
        request.setBody(new Gson().toJson(bodyMap));
        return request;
    }

    @Override
    public CommonRequest getMeetingEndRequest(String conf_id) {
        CommonRequest request = new CommonRequest();
        request.setUrl(url+"/v1"+"/voice"+"/meeting"+"/endMeeting");
        Map<String,String> bodyMap = new HashMap<>();
        bodyMap.put("conf_id",conf_id);
        request.setBody(new Gson().toJson(bodyMap));
        return request;
    }
}
